<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    输入一个数:
    <input id="num" type="text" /><br />
    <input type="button" value="是不是" onclick="fn()" /><br />
    <input id="result" type="text" />
    <!-- <script>
    function fn(){
        var num=document.getElementById("num").value;
        var result="";
        if(num%2==0){
            result="是偶数";
        }
        else{
            result="是奇数";
        }
        document.getElementById("result").value=result
    }
</script> -->
    <script>
        function evenOrOddNumber(num) {
            result.value = num % 2 == 0 ? '是偶数' : '是奇数';

        }
        function fn() {
            evenOrOddNumber()
        }
    </script>
</body>

</html>